<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('questions', function (Blueprint $table) {
            $table->id();
            $table->integer('paper_id')->default(0)->comment('问卷ID');
            $table->string('title')->comment('题目标题');
            $table->text('desc')->nullable()->comment('题目说明');
            $table->tinyInteger('type')->comment('类型 1-输入框');
            $table->tinyInteger('is_required')->nullable()->default(0)->comment('是否必填 1-是 0-否');
            $table->integer('sort')->nullable()->default(0)->comment('排序');

            $table->index('paper_id');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `questions` comment '问题'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('questions');
    }
};
